﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using System.Collections.Generic;

[Serializable]
public class web
{
    private string id;
    private string name;
    private string link;
    private string note;
    private string cate;//category
    private string cr;  //creator
    private string key;
    private string[] lans;  //languages
    public  int index;


    public string ID
    {
        get
        {
            return id;
        }
        set
        {
            this.id = value;
        }
    }

    public string Name
    {
        get
        {
            return name;
        }
        set
        {
            this.name = value;
        }
    }

    public string Link
    {
        get
        {
            return link;
        }
        set
        {
            this.link = value;
        }
    }

    public string Note
    {
        get
        {
            return note;
        }
        set
        {
            this.note = value;
        }
    }

    public string Cate
    {
        get
        {
            return cate;
        }
        set
        {
            this.cate = value;
        }
    }

    public string Cr
    {
        get
        {
            return cr;
        }
        set
        {
            this.cr = value;
        }
    }

    public string Key
    {
        get
        {
            return key;
        }
        set
        {
            this.key = value;
        }
    }


    public string[] Lans
    {
        get
        {
            return lans;
        }
        set
        {
            this.lans = value;
        }
    }

    public web()
    {

    }

    public web(XElement ex)
    {
        id = ex.Elements("ID").First().Value;
        name = ex.Elements("name").First().Value;
        link = ex.Elements("link").First().Value;
        note = ex.Elements("note").First().Value;
        cate = ex.Elements("cate").First().Value;
        cr = ex.Elements("cr").First().Value;
        key = ex.Elements("key").First().Value;
        lans = ex.Elements("lan").Select(one=>one.Value).ToArray();
    }

    public web(string id, string name, string link, string note, string cate, string cr, string key, string lans)
    {
        this.id = id;
        this.name = name;
        this.link = link;
        this.note = note;
        this.cate = cate;
        this.cr = cr;
        this.key = key;
        this.lans = lans.Split(',');

    /*
    <web>
    <ID>1</ID>
    <name>search Engine</name>
    <link>www.yahoo.com</link>
    <note>the most famous video web</note>
    <cate>video</cate>
    <!-- cate is category -->
    <cr>99</cr>
    <!-- cr is creater -->
    <key>search,entertainment,</key>
    <!--key is keyword -->
    <lan>English</lan>
    <lan>Jepanese</lan>
    <!-- lan is language -->
    </web>
    */
    }

    //public bool swapWeb(web parWeb)
    //{
    //    int tmpId = parWeb.ID;
    //    string tmpName = parWeb.Name;
    //    string tmpLink = parWeb.Link;
    //    string tmpNote = parWeb.Note;
    //    string tmpCate = parWeb.Cate;
    //    string tmpCr = parWeb.Cr;
    //    string tmpKey = parWeb.Key;
    //    string tmpLans = parWeb.Lans;        

    //}

    
   
    //public void getAllValue()
    //{       
    //    name = element.Elements("name").First().Value;
    //    link = element.Elements("link").First().Value;
    //    note = element.Elements("note").First().Value;
    //    cate = element.Elements("cate").First().Value;
    //    cr   = element.Elements("cr").First().Value;
    //    key  = element.Elements("key").First().Value;
    //    int a = element.Elements("lan").Count();
    //    for (int i = 0; i < a; i++)
    //    {
    //        lans[i] = element.Elements("lan").ElementAt(i).Value;
    //    }               
    //}

    public void updateWeb(string id, string name, string link, string note, string cate, string cr, string key, string lans)
    {
        this.id = id;
        this.name = name;
        this.link = link;
        this.note = note;
        this.cate = cate;
        this.cr = cr;
        this.key = key;
        this.lans = lans.Split(',');

        /*
        <web>
        <ID>1</ID>
        <name>search Engine</name>
        <link>www.yahoo.com</link>
        <note>the most famous video web</note>
        <cate>video</cate>
        <!-- cate is category -->
        <cr>99</cr>
        <!-- cr is creater -->
        <key>search,entertainment,</key>
        <!--key is keyword -->
        <lan>English</lan>
        <lan>Jepanese</lan>
        <!-- lan is language -->
        </web>
        */
    }
}